//
//  heapManager.hpp
//  DataStructureProject
//
//  Created by zhangbaochuan on 2020/4/9.
//  Copyright © 2020 Geex. All rights reserved.
//

#ifndef heapManager_hpp
#define heapManager_hpp

#include <stdio.h>
#include <iostream>

class HeapBase {
private:
    void putNumberInLine(int num, std::string &line, int index_cur_level, int cur_tree_width, bool isLeft);
    
    void putBranchInLine(std::string &line, int index_cur_level, int cur_tree_width);
    
public:
    int *tree;
    int count;
    //以树状打印堆结构
    virtual void testPrint();
};

class MaxHeap: public HeapBase {
private:
    int *data;
    void shiftUp(int k);
    void shiftDown(int k);
    
public:
    MaxHeap(int capacity);
    ~MaxHeap();
    int size();
    bool isEmpty();
    void insert(int v);
    int extraMax();
    void testPrint();
};

class Heapify: public HeapBase {
private:
    int *data;
    
public:
    Heapify(int arr[], int capacity);
    ~Heapify();
    
    int  size();
    bool isEmpty();
    void shiftDown(int k);
    int extraMax();
    void textPrint();
};

class IndexHeap:public HeapBase {
private:
    int *data;
    int *index;
    void shiftDown(int k);
    void shiftUp(int k);
    
public:
    IndexHeap(int capacity);
    ~IndexHeap();
    
    int size();
    bool isEmpty();
    
    void insert(int index, int v);
    int extraMax();
    
    void change(int index, int v);
    void testPrint();
};


#endif /* heapManager_hpp */
